const express = require('express');
const router = express.Router();

// 导入各个模块的路由
const authRoutes = require('./api/auth');
const dashboardRoutes = require('./api/dashboard');
const devicesRoutes = require('./api/devices');
const personnelRoutes = require('./api/personnel');
const visitorsRoutes = require('./api/visitors');
const parkingRoutes = require('./api/parking');

// 注册路由
router.use('/auth', authRoutes);
router.use('/dashboard', dashboardRoutes);
router.use('/devices', devicesRoutes);
router.use('/personnel', personnelRoutes);
router.use('/visitors', visitorsRoutes);
router.use('/parking', parkingRoutes);

// 健康检查
router.get('/health', (req, res) => {
  res.json({ 
    status: 'ok', 
    message: 'API服务运行正常',
    timestamp: new Date().toISOString(),
    endpoints: [
      '/auth - 认证相关',
      '/dashboard - 仪表盘数据',
      '/devices - 设备管理',
      '/personnel - 人员管理',
      '/visitors - 访客管理',
      '/parking - 停车管理'
    ]
  });
});

module.exports = router;
